package com.lagou.filter;

import com.lagou.bean.MethodInfo;

import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class RemoveDataThread implements Runnable{

    private Map<String, List<MethodInfo>> map;

    public RemoveDataThread(Map<String, List<MethodInfo>> map) {
        this.map = map;
    }

    @Override
    public void run() {
        System.out.println("---删除过期数据---");
        for(Map.Entry<String,List<MethodInfo>> entry : map.entrySet()){
            List<MethodInfo> methodInfoList = entry.getValue();
            Iterator<MethodInfo> iterator = methodInfoList.iterator();
            Long removeCondition = System.currentTimeMillis() - 60000;
            while (iterator.hasNext()){
                MethodInfo methodInfo = iterator.next();
                if(methodInfo.getEndTime() < removeCondition){
                    iterator.remove();
                }
            }
        }
    }
}
